#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>

int Print(int begin, int nums,int layer, char **all_relas, char **part_relas, int tot)
{
	int i,j,k;
	if(layer==0){
		for(i=begin;i<nums;i++){
			printf("{");
			for(j=0;j<tot;j++)
				printf("%s,",part_relas[j]);
			printf("%s}\n",all_relas[i]);
		}
	} else{
		for(i=begin;i<nums-layer;i++){
			part_relas[begin] = all_relas[i];
			Print(i+1, nums, layer-1, all_relas, part_relas, tot);
		}
	}
}

int main()
{
	int n,n_n,i,j,k;
	scanf("%d",&n);
	n_n = n*n;
	char *set = (char *)malloc(sizeof(char)*(2*n+2));
	scanf("%s",set);
	char *set_pro = (char*)malloc(sizeof(char)*n);
	for(i=0,j=0;i<(2*n+2);i++){
		if(isalpha(set[i]))
			set_pro[j++] = set[i];
	}
	char **relations = (char**)malloc(sizeof(char*)*n_n);
	for(i=0;i<n_n;i++){
		relations[i] = (char*)malloc(sizeof(char)*6);
	}
	k = 0;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			sprintf(relations[k++],"<%c,%c>",set_pro[i],set_pro[j]);
		}
	}
	printf("{}\n");
	for(i=0;i<n_n;i++){
		char **part_relas = (char**)malloc(i*sizeof(char *));
		for(j=0;j<i;j++)
			part_relas[j] = (char*)calloc(6,sizeof(char));
		Print(0,n_n,i,relations,part_relas,i);
	}

	return 0;
}

